package com.geek.gkfgw.service.token.bean;

import com.geek.gkfgw.util.copy.ShallowCopyUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * <h1>Redis 发送令牌消息的实体对象模型。</h1><br/>
 *
 * <h1><br/><a href="https://u.geekbang.org/subject/arch3/100614201">Java 业务架构实战营：https://u.geekbang.org/subject/arch3/100614201</a></h1><br/><h1><a href="https://gitee.com/ylimhhmily/BizArchPracticeCamp">Java 业务架构实战营代码地址：https://gitee.com/ylimhhmily/BizArchPracticeCamp</a></h1><br/><h1><a href="https://u.geekbang.org/subject/java4th/1001148?source=app_share">高级 Java 工程体系课 2023 版：https://u.geekbang.org/subject/java4th/1001148?source=app_share</a></h1><br/><h1><a href="https://time.geekbang.org/column/intro/100312101?tab=catalog">Dubbo 源码剖析与实战：https://time.geekbang.org/column/intro/100312101?tab=catalog</a></h1>
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2023/10/15 16:14
 */
@Setter
@Getter
@ToString(callSuper = true)
public class RedisTokenMsg implements Serializable {

    private static final long serialVersionUID = 7213179524221788981L;

    /** <h2>短Token, 认证令牌(时效短点)</h2> **/
    private String accessToken;
    /** <h2>过期时间，例：1693733072746</h2> **/
    private Long expireTimeMillis;

    /** <h2>用户ID，例：100000001</h2> **/
    private String userId;
    /** <h2>用户姓名，例：张三</h2> **/
    private String userName;

    /**
     * <h2>创建用于在 Redis 消息频道传输的数据对象。</h2>
     *
     * @param: accessToken
     * @param: tokenInfo
     * @return: java.lang.Object
     */
    public static RedisTokenMsg create(String accessToken, TokenInfo tokenInfo) {
        RedisTokenMsg msg = new RedisTokenMsg();

        ShallowCopyUtils.copyBeanProperties(tokenInfo, msg);
        msg.setAccessToken(accessToken);

        return msg;
    }
}